#include <future>
#include <thread>
#include <iostream>
#include <chrono>

int Add(int x, int y) {
    std::cout << "add\n";
    return x + y;
}
int main()
{
    std::packaged_task<int(int,int)> ptask(Add);
    std::future<int> fu = ptask.get_future();
    std::thread th(std::move(ptask), 10, 20);
    std::this_thread::sleep_for(std::chrono::seconds(2));
    std::cout << "--------------1----------\n";
    std::cout << fu.get() << std::endl;
    std::cout << "--------------2----------\n";
    th.join();
    return 0;
}